// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   majorChange_draft_ok.java

package draft.hr;

import include.nseer_cookie.*;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class majorChange_draft_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public majorChange_draft_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			java.io.PrintWriter out = response.getWriter();
			nseer_db_backup1 hr_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 hr_db1 = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 crm_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 crm_db1 = new nseer_db_backup1(dbApplication);
			counter count = new counter(dbApplication);
			if (hr_db.conn((String)dbSession.getAttribute("unit_db_name")) && hr_db1.conn((String)dbSession.getAttribute("unit_db_name")) && crm_db.conn((String)dbSession.getAttribute("unit_db_name")) && crm_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String human_ID = request.getParameter("human_ID");
				String config_id = request.getParameter("config_id");
				String major_time = request.getParameter("major_time");
				String vt_sql = (new StringBuilder("select * from hr_major_change where human_ID='")).append(human_ID).append("' and major_time='").append(major_time).append("' and (check_tag='5' or check_tag='9')").toString();
				ResultSet vt_rs = hr_db.executeQuery(vt_sql);
				if (vt_rs.next())
				{
					String kind_chain = request.getParameter("old_kind_chain");
					String chain_id = Divide1.getId(kind_chain);
					String chain_name = Divide1.getName(kind_chain);
					String new_kind_chain = request.getParameter("kind_chain");
					String new_chain_id = Divide1.getId(new_kind_chain);
					String new_chain_name = Divide1.getName(new_kind_chain);
					String major_first_kind_ID = "";
					String major_first_kind_name = "";
					String major_second_kind_ID = "";
					String major_second_kind_name = "";
					String salary_standard_ID = "";
					String salary_standard_name = "";
					String salary_sum = "";
					String new_first_kind_ID = "";
					String new_first_kind_name = "";
					String new_second_kind_ID = "";
					String new_second_kind_name = "";
					String new_third_kind_ID = "";
					String new_third_kind_name = "";
					String new_major_first_kind_ID = "";
					String new_major_first_kind_name = "";
					String new_major_second_kind_ID = "";
					String new_major_second_kind_name = "";
					String new_salary_standard_ID = "";
					String new_salary_standard_name = "";
					String new_salary_sum = "";
					int file_change_amount1 = 0;
					int major_change_amount1 = 0;
					String major_first_kind = request.getParameter("human_major_first_kind");
					if (major_first_kind.indexOf("//") == -1 && major_first_kind.indexOf("  /") == -1)
					{
						for (StringTokenizer tokenTO4 = new StringTokenizer(major_first_kind, "/"); tokenTO4.hasMoreTokens();)
						{
							major_first_kind_ID = tokenTO4.nextToken();
							major_first_kind_name = tokenTO4.nextToken();
						}

					}
					String major_second_kind = request.getParameter("human_major_second_kind");
					if (major_second_kind.indexOf("//") == -1 && major_second_kind.indexOf("  /") == -1)
					{
						for (StringTokenizer tokenTO5 = new StringTokenizer(major_second_kind, "/"); tokenTO5.hasMoreTokens();)
						{
							major_second_kind_ID = tokenTO5.nextToken();
							major_second_kind_name = tokenTO5.nextToken();
						}

					}
					String major_type = request.getParameter("major_type");
					String salary_standard = request.getParameter("salary_standard");
					salary_standard_ID = salary_standard.split("/")[0];
					salary_standard_name = salary_standard.split("/")[1];
					salary_sum = salary_standard.split("/")[2];
					String new_major_first_kind = request.getParameter("select4");
					if (new_major_first_kind.indexOf("//") == -1 && new_major_first_kind.indexOf("/  /") == -1)
					{
						for (StringTokenizer tokenTO14 = new StringTokenizer(new_major_first_kind, "/"); tokenTO14.hasMoreTokens();)
						{
							new_major_first_kind_ID = tokenTO14.nextToken();
							new_major_first_kind_name = tokenTO14.nextToken();
						}

					}
					String new_major_second_kind = request.getParameter("select5");
					if (new_major_second_kind.indexOf("//") == -1 && new_major_second_kind.indexOf("/  /") == -1)
					{
						for (StringTokenizer tokenTO15 = new StringTokenizer(new_major_second_kind, "/"); tokenTO15.hasMoreTokens();)
						{
							new_major_second_kind_ID = tokenTO15.nextToken();
							new_major_second_kind_name = tokenTO15.nextToken();
						}

					}
					String human_name = request.getParameter("human_name");
					String new_major_type = request.getParameter("new_major_type");
					String new_salary_standard = request.getParameter("new_salary_standard");
					for (StringTokenizer tokenTO16 = new StringTokenizer(new_salary_standard, "/"); tokenTO16.hasMoreTokens();)
					{
						new_salary_standard_ID = tokenTO16.nextToken();
						new_salary_standard_name = tokenTO16.nextToken();
						new_salary_sum = tokenTO16.nextToken();
					}

					String register = request.getParameter("register");
					String register_time = request.getParameter("register_time");
					String bodyc = new String(request.getParameter("remark1").getBytes("UTF-8"), "UTF-8");
					String remark1 = exchange.toHtml(bodyc);
					try
					{
						String sql = (new StringBuilder("update hr_major_change set new_chain_id='")).append(new_chain_id).append("',new_chain_name='").append(new_chain_name).append("',new_human_major_first_kind_ID='").append(new_major_first_kind_ID).append("',new_human_major_first_kind_name='").append(new_major_first_kind_name).append("',new_human_major_second_kind_ID='").append(new_major_second_kind_ID).append("',new_human_major_second_kind_name='").append(new_major_second_kind_name).append("',human_name='").append(human_name).append("',major_type='").append(major_type).append("',salary_standard_ID='").append(salary_standard_ID).append("',salary_standard_name='").append(salary_standard_name).append("',salary_sum='").append(salary_sum).append("',new_major_type='").append(new_major_type).append("',new_salary_standard_ID='").append(new_salary_standard_ID).append("',new_salary_standard_name='").append(new_salary_standard_name).append("',new_salary_sum='").append(new_salary_sum).append("',register='").append(register).append("',register_time='").append(register_time).append("',remark1='").append(remark1).append("' where human_ID='").append(human_ID).append("' and major_time='").append(major_time).append("'").toString();
						hr_db.executeUpdate(sql);
						response.sendRedirect("draft/hr/majorChange_ok.jsp?finished_tag=0");
					}
					catch (Exception ex)
					{
						ex.printStackTrace();
					}
				} else
				{
					response.sendRedirect("draft/hr/majorChange_ok.jsp?finished_tag=1");
				}
				hr_db.commit();
				hr_db1.commit();
				crm_db.commit();
				crm_db1.commit();
				hr_db.close();
				hr_db1.close();
				crm_db.close();
				crm_db1.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
